package jinyilw.swing.visuals;

import jinyilw.swing.i18n.LanguageTools;

import javax.swing.JOptionPane;
import java.awt.Component;

public class MessageDialogs
{
	public static void showFailureString(Component parent, String msg)
	{
		final String title = LanguageTools.getText("failure");
		JOptionPane.showMessageDialog(parent, msg, title,
				JOptionPane.ERROR_MESSAGE);
	}

	public static void showFailureTextKey(Component parent,
			String textKey)
	{
		final String msg = LanguageTools.getText(textKey);
		showFailureString(parent, msg);
	}

	public static  void showErrorString(Component parent, String msg)
	{
		final String title = LanguageTools.getText("failure");
		JOptionPane.showMessageDialog(parent, msg, title,
				JOptionPane.ERROR_MESSAGE);
	}

	public static  void showErrorTextKey(Component parent, String textKey)
	{
		final String msg = LanguageTools.getText(textKey);
		showErrorString(parent, msg);
	}

	public static  void showException(Component parent, Throwable exn,
			String title)
	{
		JOptionPane.showMessageDialog(parent, exn.getLocalizedMessage(), title,
				JOptionPane.ERROR_MESSAGE);
	}

	public static  void showExceptionError(Component parent, Throwable exn)
	{
		showException(parent, exn, LanguageTools.getText("error"));
	}

	public static  void showExceptionFailure(Component parent,
			Throwable exn)
	{
		showException(parent, exn, LanguageTools.getText("failure"));
	}

	public static  void showExceptionWarning(Component parent,
			Throwable exn)
	{
		JOptionPane.showMessageDialog(parent, exn.getLocalizedMessage(),
				LanguageTools.getText("warning"), JOptionPane.WARNING_MESSAGE);
	}

	public static  void showInfoNoteString(Component parent, String msg)
	{
		final String title = LanguageTools.getText("note");
		JOptionPane.showMessageDialog(parent, msg, title,
				JOptionPane.INFORMATION_MESSAGE);
	}

	public static  void showInfoNoteTextKey(Component parent,
			String textKey)
	{
		final String msg = LanguageTools.getText(textKey);
		showInfoNoteString(parent, msg);
	}

	public static  void showCongratsTextKey(Component parent,
			String textKey)
	{
		final String title = LanguageTools.getText("congratulations");
		final String msg = LanguageTools.getText(textKey);
		JOptionPane.showMessageDialog(parent, msg, title,
				JOptionPane.INFORMATION_MESSAGE);
	}
}
